package net.towee.server.rpc.services;

import java.util.List;
import java.util.Map;

import net.towee.model.account.AccountData;
import net.towee.model.account.AccountGroup;
import net.towee.model.account.AccountIdentity;
import net.towee.model.account.AccountProfile;
import net.towee.model.account.Board;
import net.towee.model.account.ContactsGroup;
import net.towee.model.account.Gadget;
import net.towee.model.account.Role;
import net.towee.model.discussion.Discussion;
import net.towee.model.discussion.DiscussionSubject;
import net.towee.model.discussion.Message;
import net.towee.model.group.GroupData;
import net.towee.model.group.GroupEnterRequest;
import net.towee.model.group.GroupIdentity;
import net.towee.model.group.GroupProfile;
import net.towee.model.repo.AttachmentIdentity;
import net.towee.model.repo.AttachmentInfo;
import net.towee.model.repo.DocumentData;
import net.towee.model.repo.DocumentIdentity;
import net.towee.model.repo.DocumentPatch;
import net.towee.model.repo.DocumentType;
import net.towee.model.repo.NodeData;
import net.towee.model.utils.Pair;

import com.google.gwt.user.client.rpc.AsyncCallback;

public interface ToweeServiceAsync {
	void getCurrentAccount(AsyncCallback<AccountData> asyncCallback);

	void getAccountProfile(String accountId, AsyncCallback<AccountProfile> asyncCallback);

	void getAccountIdentity(String accountId, AsyncCallback<AccountIdentity> asyncCallback);

	void checkAccountWithNicknameExists(String nickname, AsyncCallback<Boolean> asyncCallback);

	void updateAccountIdentity(AccountIdentity identity, AsyncCallback<Boolean> asyncCallback);

	void updateAccountProfile(AccountProfile profile, AsyncCallback<Boolean> asyncCallback);

	void putSetting(String key, String val, AsyncCallback<Boolean> asyncCallback);

	void updateSettings(Map<String, String> settingsMap, AsyncCallback<Boolean> handler);

	void onAccountIdentityUpdated(AccountIdentity result, String node,
			AsyncCallback<AccountIdentity> asyncCallback);

	void onAccountProfileUpdated(AccountProfile result, String node,
			AsyncCallback<AccountProfile> asyncCallback);

	void onOnlineStateChanged(Pair<String, Boolean> result, String node,
			AsyncCallback<Pair<String, Boolean>> asyncCallback);

	void createAttachmentIdentity(String rawAttachmentId, AsyncCallback<AttachmentIdentity> handler);

	void getAttachmentInfo(String attachmentId, AsyncCallback<AttachmentInfo> asyncCallback);

	void onUserAddedToContacts(Pair<AccountIdentity, String> result, String node, AsyncCallback< Pair<AccountIdentity, String> > asyncCallback);

	void onUserRemovedFromContacts(Pair<AccountIdentity, String> result, String node,
			AsyncCallback<Pair<AccountIdentity, String>> asyncCallback);

	void createContactsGroup(String name, AsyncCallback<ContactsGroup> handler);

	void removeContactsGroup(String id, AsyncCallback<Boolean> handler);

	void renameContactsGroup(String id, String newName, AsyncCallback<Boolean> handler);

	void addContactsToGroup(String id, List<AccountIdentity> accounts, AsyncCallback<Boolean> handler);

	void removeContactsForomGroup(String id, List<String> accountIds, AsyncCallback<Boolean> handler);

	void addBoard(Board board, AsyncCallback<Board> asyncCallback);

	void removeBoard(String boardId, AsyncCallback<Boolean> handler);

	void renameBoard(String boardId, String newName, AsyncCallback<Boolean> handler);

	void attachGroupToBoard(String boardId, String groupId, AsyncCallback<GroupIdentity> handler);

	void detachGroupFromBoard(String boardId, String groupId, AsyncCallback<Boolean> handler);

	void getDiscussion(String id, DiscussionSubject subject, int offset, int limit, AsyncCallback<Discussion> handler);

	void onDiscussionMessageUpdate(Pair<String, Message> result, String node, AsyncCallback<Pair<String, Message>> asyncCallback);

	void addDiscussionMessage(String discId, DiscussionSubject subject, Message mess, AsyncCallback<String> handler);

	void changeDiscussionMessage(String discId, DiscussionSubject subject, Message mess, AsyncCallback<Boolean> handler);

	void onDocumentUpdate(DocumentData doc, String node, AsyncCallback<DocumentData> asyncCallback);

	void onDocumentDelete(List<DocumentIdentity> identity, String node, AsyncCallback<List<DocumentIdentity>> asyncCallback);

	void onDocumentRated(Pair<AccountIdentity, DocumentIdentity> result, String node,
			AsyncCallback<Pair<AccountIdentity, DocumentIdentity>> asyncCallback);


	void getDocuments(List<String> groupId, List<DocumentType> types, int offset, int limit,
			AsyncCallback<List<DocumentData>> handler);

	void getDocuments(String docId, AsyncCallback<DocumentData> handler);

	void saveDocument(DocumentData doc, String parentNodeId, AsyncCallback<DocumentData> handler);

	void changeDocument(DocumentData doc, String explain, AsyncCallback<DocumentData> handler);

	void tupDocument(String docId, AsyncCallback<Boolean> handler);

	void getDocumentPatchs(List<String> neededPatchs, AsyncCallback<Map<String, DocumentPatch>> asyncCallback);

	void onUserLeaveFromGroup(GroupIdentity result, String node,
			AsyncCallback<GroupIdentity> asyncCallback);

	void onUserEnterToGroup(GroupIdentity result, String node, AsyncCallback<AccountGroup> asyncCallback);

	void getGroupData(String id, AsyncCallback<GroupData> asyncCallback);

	void findGroup(String str, int offset, int limit, AsyncCallback<List<GroupProfile>> asyncCallback);

	void getGroupMembers(String groupId, int offset, int limit,
			AsyncCallback<List<Pair<AccountIdentity, AccountGroup>>> handler);

	void whosOnline(String groupId, int offset, int limit, AsyncCallback<List<AccountIdentity>> handler);

	void getGroupsByIds(List<String> ids, AsyncCallback<List<GroupProfile>> handler);

	void addEnterRequest(String groupId, String accountId, String testAnsw, AsyncCallback<Boolean> handler);

	void processEnterRequest(String groupId, String accountId, AsyncCallback<Boolean> handler);

	void getEnterRequests(String groupId, int offset, int limit,
			AsyncCallback<List<GroupEnterRequest>> handler);

	void createGroup(GroupData group, AsyncCallback<GroupData> asyncCallback);

	void enterToGroup(String groupId, String testAnswer, AsyncCallback<AccountGroup> handler);

	void leaveGroup(String groupId, AsyncCallback<Boolean> handler);

	void kickUserFromGroup(String groupId, String userId, AsyncCallback<Boolean> handler);

	void updateGroupProfile(GroupProfile groupProfile, AsyncCallback<Boolean> asyncCallback);

	void updatePrintName(String groupId, String newName, AsyncCallback<Boolean> asyncCallback);

	void getGroupTestQuestion(String groupId, AsyncCallback<String> handler);

	void onNodesChange(List<NodeData> treeNode, String node, AsyncCallback<List<NodeData>> asyncCallback);

	void onNodesRemoved(List<NodeData> nodes, String node, AsyncCallback<List<NodeData>> asyncCallback);

	void getRootNodes(String groupId, AsyncCallback<List<NodeData>> asyncCallback);

	void getSubTree(String groupId, String parentNodeId, AsyncCallback<List<NodeData>> asyncCallback);

	void getSubTreeByPath(String groupId, String path, AsyncCallback<List<NodeData>> asyncCallback);

	void getSubTreeToPath(String groupId, String path, AsyncCallback<List<NodeData>> asyncCallback);

	void getNode(String nodeId, AsyncCallback<NodeData> asyncCallback);

	void saveNode(NodeData node, AsyncCallback<NodeData> asyncCallback);

	void moveNodes(String groupId, String newParentNode, List<String> nodeIds,
			AsyncCallback<Boolean> asyncCallback);

	void renameNode(String groupId, String nodeId, String newName, AsyncCallback<Boolean> asyncCallback);

	void putToTrash(String groupId, List<String> nodeIds, AsyncCallback<Boolean> asyncCallback);

	void removeNode(String groupId, List<String> nodeIds, AsyncCallback<Boolean> asyncCallback);

	void onNodesToTrash(List<String> nodeIds, String node, AsyncCallback<List<NodeData>> asyncCallback);

	void onNodesMoved(Pair<String, List<NodeData>> result, String node, AsyncCallback<Pair<String, List<NodeData>>> asyncCallback);

	void checkNodeExisting(String nodeName, String groupNode, String parentNode,
			AsyncCallback<Boolean> asyncCallback);

	void updateBoard(Board currentBoard, AsyncCallback<Void> asyncCallback);

	void findAccount(String str, int offset, int limit, AsyncCallback<List<AccountIdentity>> asyncCallback);

	void attachGadgetToBoard(String boardId, Gadget g, AsyncCallback<Gadget> asyncCallback);

	void detachGadgetFromBoard(String boardId, String gadgetId, AsyncCallback<Boolean> asyncCallback);

	void getRecentDocumentsCount(List<String> groupId, List<DocumentType> types,
			AsyncCallback<Integer> handler);

	void findDocument(String str, List<String> groupId, String authorId, List<DocumentType> type,
			int offset, int limit, AsyncCallback<List<DocumentData>> asyncCallback);

	void updateGadget(String boardId, Gadget g, AsyncCallback<Boolean> asyncCallback);

	void updateGroupTestQuest(String id, String quest, String questAnswer,
			AsyncCallback<Boolean> asyncCallback);

	void applyRoleToUser(String roleId, String userId, String groupId,
			AsyncCallback<Boolean> asyncCallback);

	void onUserRoleUpdated(Pair<Role, String> result, String node, AsyncCallback<Pair<Role, String>> asyncCallback);

	void setDefaultRole(String groupId, Role role, AsyncCallback<Void> asyncCallback);

	void getAllGroup(int offset, int limit, AsyncCallback<List<GroupProfile>> asyncCallback);

	void sendFeedback(String userName, String message, AsyncCallback<Boolean> asyncCallback);

	void updateCookieId(AsyncCallback<String> callback);
}
